%%%-----------------------------------
%%% @Module  : pt_15
%%% @Author  : xws
%%% @Created : 2016.08.18
%%% @Description: 13物品信息
%%%-----------------------------------
-module(pt_15).
-export([read/2, write/2]).
-include("common.hrl").
-include("proto_15_recharge.hrl").

%%
%%客户端 -> 服务端 ----------------------------
%%

%% c2s获取商城物品
read(15000, Bin) ->
	{ClientData, _} = proto_read:unpack(c2s_get_player_recharge_data, Bin),	
	{c2s_get_player_recharge_data, RechargeId} = ClientData,
    {ok, [RechargeId]};

%% c2s测试充值
read(15002, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_test_recharge, Bin), 
    {c2s_test_recharge, RechargeId} = ClientData,
    {ok, [RechargeId]};

%% 15003 领取超值礼包每日奖励
read(15003, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_get_daily_super_award, Bin), 
    {c2s_get_daily_super_award, PlayerId} = ClientData,
    {ok, [PlayerId]};


read(_Cmd, _R) ->
    ?ERROR_MSG("~s pt_15 reading cmd_[~p], Data:~p~n",[misc:time_format(game_timer:now()), _Cmd, _R]),
    {error, no_match}.

%%
%%服务端 -> 客户端 ------------------------------------
%%
%% s2c兑换商城物品
write(15000, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_get_player_recharge_data, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(15000, ServerData)};

%% 15001 通知玩家充值
write(15001, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_notify_player_recharge, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(15001, ServerData)};

%% 15003 通知玩家充值
write(15003, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_get_daily_super_award, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(15003, ServerData)};


%% 15004 通知玩家超值礼包信息
write(15004, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_notify_player_super_recharge, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(15004, ServerData)};

%% 15005 通知玩家限时礼包信息
write(15005, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_time_limit_recharge, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(15005, ServerData)};


write(Cmd, _R) ->
    ?ERROR_MSG("~s pt_15 writting cmd_[~p], Data:~p~n",[misc:time_format(game_timer:now()), Cmd, _R]),
    {ok, pt:pack(0, <<>>)}.
